package com.rinlink.jbcodec.transform;

import com.rinlink.jbcodec.exception.TransformException;
import io.netty.buffer.ByteBufUtil;

import java.nio.ByteBuffer;

public class BytesToHexString extends BytesToString {

    public BytesToHexString(ByteBuffer byteBuffer, int bytes) {
        super(byteBuffer, bytes);
    }

    @Override
    public String transform() throws TransformException {
        ByteBuffer buffer = getByteBuffer();
        byte[] strByte = new byte[getBytes()];
        buffer.get(strByte);
        return ByteBufUtil.hexDump(strByte);
    }
}
